<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => (this.columns = columns)"
    >
    </FilterTable>
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <el-button @click="closeDrawer(2)" type="primary">保 存</el-button>
      <el-button @click="closeDrawer(3)" type="primary">确 定</el-button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      formList: this.createdFrom(),
      columns: this.createdTable(),
      fetchParams: {},
      fetchApi: () => {}
    };
  },
  methods: {
    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '基本信息'
        },
        {
          type: 'SELECT',
          label: '事业部',
          fieldName: 'syb',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'DATE',
          label: '月份',
          fieldName: 'yf',
          placeholder: '请选择',
          disabled: true,
          dateType: 'month'
        },
        {
          type: 'SELECT',
          label: '车系名称',
          fieldName: 'cxmc',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '车系车型',
          fieldName: 'cxcx',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '任务数量(批售)',
          fieldName: 'rwslps',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '任务数量(终端)',
          fieldName: 'rwslzd',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'BREAK_SPACE',
          label: '经销商任务信息'
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '经销商代码',
          dataIndex: 'jxsdm',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商名称',
          dataIndex: 'jxsmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '品牌名称',
          dataIndex: 'ppmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车系名称',
          dataIndex: 'cxmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车型名称',
          dataIndex: 'cxmc2',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '月份',
          dataIndex: 'yf',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '任务数量(批售)',
          dataIndex: 'rwslps',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          defaultEditable: true,
          editType: 'number'
        },
        {
          title: '任务数量(终端)',
          dataIndex: 'rwslzd',
          sorter: true,
          filter: true,
          filterType: 'input',
          editable: true,
          defaultEditable: true,
          editType: 'number'
        }
      ];
    },
    changeHandle(val) {
      this.fetchParams = Object.assign({}, this.fetchParams, val);
    },
    closeDrawer(type) {},
    selectChangeHandle(val) {}
  }
};
</script>
